#!/usr/bin/env node

const http= require('http'),
  url = require('url');
const addr = process.argv[2] ||  'http://www.baidu.com';
const options = url.parse(global.encodeURI(addr));
options.headers = {
  'User-Agemt':'01-my-curl.js'
};
http.get(options,(res)=>{
  console.log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  console.log(res.headers);
  console.log('');
  res.pipe(process.stdout);
  
});
